package com.soft.mainsite.mybatis.mapper;

import com.soft.mainsite.mybatis.model.TSysRolePermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * TSysRolePermissionMapper
 *
 * @author Jin
 * @create 2017-06-16
 **/
public interface TSysRolePermissionMapper {

    /**
     * 根据id删除
     *
     * @param id
     * @return
     */
    int deleteByPrimaryKey(Integer id);

    /**
     * 保存
     *
     * @param record
     * @return
     */
    int insert(TSysRolePermission record);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    TSysRolePermission selectByPrimaryKey(Integer id);

    /**
     * 查询所有
     *
     * @return
     */
    List<TSysRolePermission> selectAll();

    /**
     * 更新
     *
     * @param record
     * @return
     */
    int updateByPrimaryKey(TSysRolePermission record);

    /**
     * 根据角色id和权限id查询数量
     *
     * @param roleId
     * @param permissionId
     * @return
     */
    @Select("select count(0) from t_sys_role_permission where  role_id =#{roleId} and permisson_id =#{permissionId} ")
    int selectCountByRoleIdAndPermissionId(@Param("roleId") Integer roleId, @Param("permissionId") Integer permissionId);

    /**
     * 根据角色id和权限id查询
     *
     * @param roleId
     * @param permissionId
     * @return
     */
    @Deprecated
    @Select("select * from t_sys_role_permission where  role_id =#{roleId} and permisson_id =#{permissionId} ")
    TSysRolePermission selectByRoleIdAndPermissionId(@Param("roleId") Integer roleId, @Param("permissionId") Integer permissionId);

    /**
     * 根据角色id删除
     *
     * @param roleId
     * @return
     */
    int delectByRoleId(@Param("roleId") Integer roleId);

    /**
     * 根据权限id删除
     *
     * @param permissionId
     * @return
     */
    int delectByPermissionId(@Param("permissionId") Integer permissionId);
}